package com.xmcc.controller;

import com.xmcc.common.ResultJson;
import com.xmcc.dto.SysUserDto;
import com.xmcc.pojo.SysUser;
import com.xmcc.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("sys/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @RequestMapping("insert.json")
    public @ResponseBody  ResultJson insert(SysUserDto sysUserDto){
        sysUserService.insert(sysUserDto);
        return ResultJson.success();
    }

    @RequestMapping("update.json")
    public @ResponseBody  ResultJson update(SysUserDto sysUserDto){
        sysUserService.update(sysUserDto);
        return ResultJson.success();
    }

    @RequestMapping("updatePassword.json")
    public @ResponseBody  ResultJson updatePassword(Integer id,String oldPassword,String newPassword){
        sysUserService.updatePassword(id,oldPassword,newPassword);
        return ResultJson.success();
    }


   /* @RequestMapping("userList.json")
    public @ResponseBody  ResultJson userList(Integer curPage,Integer pageSize){
        PageCommon<SysUser> pageCommon = sysUserService.queryAll(curPage, pageSize);
        return ResultJson.success(pageCommon);
    }
*/
    @RequestMapping("userList2.json")
    public @ResponseBody  ResultJson userList2(Integer deptId){
        List<SysUser>  list = sysUserService.queryByDeptId(deptId);
        return ResultJson.success(list);
    }


}
